﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace ucFilesOper.common
{
   public static  class FileHelper
   
    {



       public  static bool ChangeFileName(FileInfo tempFile, string fileNewName)
       {
           string fileNewFullName = Path.Combine(tempFile.DirectoryName, fileNewName);
           int i = 1;
           while (File.Exists(fileNewFullName))
           {
               string s1 = Path.GetDirectoryName(fileNewFullName);
               string s2 = Path.GetFileNameWithoutExtension(fileNewFullName);
               string s3 = Path.GetExtension(fileNewFullName);
               fileNewFullName = s1 + @"\" + s2 + i + "." + s3;
               i++;
           }
           try
           {
               tempFile.MoveTo(fileNewFullName);
           }
           catch (Exception)
           {
               return false;
           }
           return true;
       }
    }
}
